﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.ModelBinding;
using OUSMS.AppLogic.BusinessLogicLayer;
using OUSMS.AppLogic.DataAccessLayer;
using OUSMS.Helpers;

namespace OUSMS
{
    public partial class UserDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Label studyAreaLbl = userInfoFormView.FindControl("studyAreaLbl") as Label;
                UsersBLL usersBLL = new UsersBLL();
                Users userEntity = usersBLL.GetUsersByID(Convert.ToInt64(Request.QueryString["UID"])).FirstOrDefault();

                foreach (UserStudyAreas userStudyArea in userEntity.UserStudyAreas)
                {
                    studyAreaLbl.Text += userStudyArea.StudyAreas.Name + ";";
                }
            }
        }

        public IQueryable<Users> GetUsersByID([QueryString("UID")]long uid)
        {
            UsersBLL usersBLL = new UsersBLL();
            return usersBLL.GetUsersByID(uid);
        }

        protected void backBtn_Click(object sender, EventArgs e)
        {
            Response.Redirect("UserManageList.aspx");
        }
    }
}